package com.zr.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.zr.dao.BaseDao;
import com.zr.dao.PointPriceDao;
import com.zr.datamodel.PointPriceDM;
import com.zr.dto.PointPriceDto;
import com.zr.service.PointPriceService;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
@Service("pointPricevice")
public class PointPriceServiceImpl implements PointPriceService{
	@Resource
	private BaseDao<PointPriceDM> baseDao;
	@Resource PointPriceDao<PointPriceDM> pointPriceDao;
	@Override 
	public JSONObject findPointPriceMsg(int page, int rows) {
		// TODO Auto-generated method stub
		JSONObject obj=new JSONObject();
		obj.put("total", pointPriceDao.findPointPriceCount());
		obj.put("rows", pointPriceDao.findPointPriceMsg(page, rows));
		return obj;
	}
	@Override
	public void addPointPrice(String startName, String pointName, int firstPrice, int nextPrice, int firstcPrice,
			int nextcPrice) {
		// TODO Auto-generated method stub
		pointPriceDao.addPointPrice(startName, pointName, firstPrice, nextPrice, firstcPrice, nextcPrice);
	}
	@Override
	public void delPointPrice(String[] ids) {
		// TODO Auto-generated method stub
		for (int i = 0; i < ids.length; i++) {
			pointPriceDao.delPointPrice(Integer.valueOf(ids[i]));
		}
	}
	@Override
	public void updatePointPrice(PointPriceDM pointPrice) {
		// TODO Auto-generated method stub
		pointPriceDao.updatePointPrice(pointPrice);
	}
	@Override
	public JSONObject selectPointPriceByPointName(String pointName,int page, int rows) {
		// TODO Auto-generated method stub
		JSONObject obj=new JSONObject();
		try {
			obj.put("total", pointPriceDao.selectPointPriceByPointNameCount(pointName));
			obj.put("rows", pointPriceDao.selectPointPriceByPointNameMsg(pointName, page, rows));
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return obj;
	}
}
